import request from "@/utils/request"

const getCityDetail = (code) => {
    return request({
        url: `/api/cityDetail/code/${code}`,
        method: 'get'
    })
}

const getCityPopularSpots = (code, limit) => {
    return request({
        url: `/api/cityDetail/spots/top/${code}/${limit}`,
        method: 'get'
    })
}

const getAllCitySpots = (code, page, pageSize, filters = {}) => {
    return request({
        url: `/api/cityDetail/spots/${code}`,
        method: 'get',
        params: {
            page,
            pageSize,
            type: filters.type || '',
            priceRange: filters.priceRange || '',
            rating: filters.rating || '',
            sortKey: filters.sortKey || 'name',
            sortDirection: filters.sortDirection || 'asc'
        }
    })
}

const getCityFoods = (cityId, category) => {
    return request({
        url: `/api/cityDetail/foods/${cityId}`,
        method: 'get',
        params: {
            category
        }
    })
}

const getCityTravelNotes = (code) => {
    return request({
        url: `/api/cityDetail/travelogues/${code}`,
        method: 'get'
    })
}

const getRelatedCities = (cityId, limit) => {
    return request({
        url: `/city/related/${cityId}/${limit}`,
        method: 'get'
    })
}

const getSpotDetail = (spotId) => {
    return request({
        url: `/spot/detail/${spotId}`,
        method: 'get'
    })
}

const getSpotReviews = (spotId, page, pageSize) => {
    return request({
        url: `/spot/reviews/${spotId}`,
        method: 'get',
        params: {
            page,
            pageSize
        }
    })
}

export {
    getCityDetail,
    getCityPopularSpots,
    getAllCitySpots,
    getCityFoods,
    getCityTravelNotes,
    getRelatedCities,
    getSpotDetail,
    getSpotReviews
}